<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <!--引入vue.js-->
    <script src="js/vue.js"></script>

    <!--引入 element js css-->
    <link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
    <script src="element-ui/lib/index.js"></script>
    <script src="js/axios-0.18.0.js"></script>
</head>
<body>
<div id="app">
    <div style="text-align: center">
        <el-button style="float: right;margin-right: 50px;margin-top: 15px;" @click="go">交作业啦！！！</el-button>
        <h2 style="color:red;">作业是对自己学习结果的检验，可以通过作业的完成度及时复盘、查缺补漏</h2>
        <h2 style="color:red;">请正确对待，并及时完成，严禁抄袭！！！</h2>
    </div>

    <hr>

    <el-upload
            class="upload-demo"
            drag
            action="/cdm/hw/upload"
            :on-success="success"
            :on-error="error"
            multiple>
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">
            <b style="font-size: 13px">
            只能上传文件或者zip压缩包,项目打压缩包之前，请将target目录删除 <br>
            </b>
            <br>
            <br>
            <span style="font-size: 15px;color: red;">
                注意：文件命名格式为 - 姓名.后缀。例：张三.txt、张三.zip; 文件大小不超过10M
            </span>
        </div>
    </el-upload>
</div>
</body>

<script>
    new Vue({
        el: "#app",
        methods:{
            go(){
                location.href = "teacher.html";
            },
            success(response, file, fileList){
                if (response == "success"){
                    this.$message({
                        message: '作业提交成功！文件名为:' + file.name,
                        type: 'success'
                    });
                }else{
                    this.$message({
                        message: '作业提交失败 ：失败原因' + response,
                        type: 'warning'
                    });
                }
            },
            error(err, file, fileList){
                this.$message({
                    message: '作业提交失败，请检查文件名格式，文件大小，重新提交！',
                    type: 'warning'
                });
            }
        }
    });
</script>

</html>